<?php
use app\assets\CommissionAsset;
use yii\helpers\Html;

CommissionAsset::register($this);
?>

<div class="col-md-4 col-sm-6">
<form class="form-horizontal " id="commissionForm">
    <fieldset>
        <div id="legend" class="">
            <legend class="">佣金比例设置(最大为1，即全部)</legend>
        </div>
        <div class="form-group col-md-12 ">

            <!-- Text input-->
            <label class="control-label" for="input01">一级分销商</label>
            <div class="controls">
                <input type="text" placeholder="佣金比例" class="form-control" id="input01" value=<?= Html::encode($model->first_rate) ?> check-type="required figure">
            </div>
        </div>

        <div class="form-group col-md-12">

            <!-- Text input-->
            <label class="control-label" for="input01">二级分销商</label>
            <div class="controls">
                <input type="text" placeholder="佣金比例" class="form-control" id="input02" value=<?= Html::encode($model->second_rate) ?> check-type="required figure">
            </div>
        </div>

        <div class="form-group col-md-12">

            <!-- Text input-->
            <label class="control-label" for="input01">三级分销商</label>
            <div class="controls">
                <input type="text" placeholder="佣金比例" class="form-control" id="input03" value=<?= Html::encode($model->third_rate) ?> check-type="required figure">
            </div>
        </div>

        <div class="form-group col-md-12">
            <div class="controls">
                <p class="btn btn-primary">确认修改</p>
            </div>
        </div>

    </fieldset>
</form>
</div>

<script>

    $("#commissionForm").validation({icon: true, reqmark: false});

    $(function() {


        //正则


        $('.btn-primary').click(function(){

            //正则提示写法
            if ($("#commissionForm").valid()==false){
                alert('填写信息有误,请检查');
                return false;
            }


            $.ajax({
                url: "update-commission",
                data:{'first_rate':$('#input01').val(),'second_rate':$('#input02').val(),'third_rate':$('#input03').val()},
                dataType: "json",
                success: function (data) {

                    console.log('data--->'+data);
                    alert('修改成功！');

                }
            });


        });

    });

</script>
